import { createStore } from 'vuex'

export default createStore({
  state: {
    user: {},//用户信息
    btnDisabled: false,//按钮二次防点击
  },
  mutations: {
    // 存放登陆者信息
    SAVEUSERINFO(state, data) {
      state.user = data;
    },
    // 改变按钮状态
    CHANGEBTNSTATUS(state, data) {
      state.btnDisabled = data;
    }
  },
  getters: {
    btnRole(state) {
      return function (btnsName) {
        // 过滤出按钮
        let btnNames = [];
        state.roleBtn.forEach(item => {
          btnNames.push(item.authorityName);
        });
        if (btnNames.includes(btnsName)) {
          return true;
        } else {
          return false;
        };
      }
    },
    enterEvent(state) {
      return function (that) {
        let a=that
        document.onkeydown = function (e,that) {
          var key = window.event.keyCode;
          if (key === 13) {
            return a.searchBtn();
          }
        };
      }
    }
  },
  actions: {
  },
  modules: {
  }
})
